package com.zrrd.mq.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class SpringRabbitListener {

    /*@RabbitListener(bindings = @QueueBinding(
            value = @Queue(name ="camq.simple.queue"),
            exchange = @Exchange(name = "camq.topic",type = ExchangeTypes.TOPIC),
            key = {"camq.simple"}
    ))
    public void listenSimpleQueue(String msg) {
        System.out.println("消费者接收到simple.queue的消息：【" + msg + "】");
        System.out.println(1/0);

        log.debug("消息处理完成..........");
    }*/


    /*@RabbitListener(bindings = @QueueBinding(
            value = @Queue(name ="error.queue"),
            exchange = @Exchange(name = "error.direct",type = ExchangeTypes.TOPIC),
            key = {"err6666or","err667or","error"}
    ))
    public void listenErrorQueue(String msg) {
        System.out.println("消费者接收到simple.queue的消息：【" + msg + "】");
        //System.out.println(1/0);

        log.debug("error.queue...消息处理完成..........");
    }*/


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name ="camq.simple.queue",
                    durable = "true",
                    arguments = @Argument(name = "x-queue-mode",value = "lazy")
            ),
            exchange = @Exchange(name = "camq.topic",type = ExchangeTypes.TOPIC),
            key = {"camq.simple"}
    ))
    public void listenSimpleQueue02(String msg) {
        System.out.println("消费者接收到simple.queue的消息：【" + msg + "】");
        //System.out.println(1/0);

        log.debug("消息处理完成..........");
    }
}
